package com.houdoudou.customer;

import com.houdoudou.customer.common.Constant;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;

public class WelcomeAct extends Activity{
  
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_welcome);
		app_config();
		
		}
  private void app_config(){
		  
		  SharedPreferences sharedPreferences = WelcomeAct.this.getSharedPreferences("config", Context.MODE_PRIVATE);
		  Editor editor = sharedPreferences.edit();   
		  editor.clear(); editor.commit();
		  boolean base_empty=false,owner_empty=false;
		  boolean isFirst = sharedPreferences.getBoolean("isFirst", true);
		  if(isFirst){
			  
		  }
		  
		  if(sharedPreferences.getString("BaseUrl", "").isEmpty()) base_empty=true;
	       if(sharedPreferences.getString("CustomerUrl", "").isEmpty()) owner_empty=true;
	       if(base_empty||owner_empty){
	    	  System.out.println("-------------BaseUrl empty-----------");
	    	   editor.putString("BaseUrl", "http://192.168.1.115"); 
	    	   editor.putString("CustomerUrl", ":8080/houdoudou/customer4App");
	       }
	       editor.commit(); 
	       //可能上次提交未更新 重定义。
	       SharedPreferences sharedPreferences2 = WelcomeAct.this.getSharedPreferences("config", Context.MODE_PRIVATE);
	     //  Constant.BaseUrl=sharedPreferences2.getString("BaseUrl", "");
	     //  Constant.CustomerUrl=sharedPreferences2.getString("CustomerUrl", "");  
	       
	       /*-------------判断有没有设置机器----------
	       Constant.Machine_ID=sharedPreferences2.getInt("Machine_ID",0);
	       if(Constant.Machine_ID==0){	    	   
	    	   Intent intent= new Intent(WelcomeAct.this, ChooseMachineActivity.class);    	   
			     startActivity(intent);
	       }else{
	    	   Intent intent= new Intent(WelcomeAct.this, CustomerMainActivity.class);    	   
			     startActivity(intent);
	       }
	       -*/
	       WelcomeAct.this.finish();
	  }
}
